const getOptions = () => {
    const pages = getCurrentPages()
    const options = pages[pages.length - 1].options
    return options
}

const getRoute = () => {
    const pages = getCurrentPages()
    const route = pages[pages.length - 1].route
    return route
}

const navigateBack = () => {
    const pages = getCurrentPages()
    if (pages.length == 1) {
        uni.reLaunch({
            url: '/pages/index/index'
        })
    } else {
        uni.navigateBack()
    }
}
const navigateTo = (herf) => {
    // #ifdef APP || MP-WEIXIN
    uni.setStorage({
        data: herf,
        key: "webUrl",
        success: function(t) {
            uni.navigateTo({
                url: "/pages/web/index"
            });
        }
    });
    // #endif

    // #ifdef H5
    window.location.href = herf
    // #endif
}

module.exports = {
    getOptions,
    navigateBack,
    getRoute,
    navigateTo,
}